package com.gt.web.controller.app;

import com.gt.app.domain.dto.EsColonoscopyCheckInfoDto;
import com.gt.app.service.EsColonoscopyCheckInfoService;
import com.gt.common.core.domain.AjaxResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 肠镜检查相关资料表 前端控制器
 * </p>
 *
 * @author caidesheng
 */
@Slf4j
@RestController
@RequestMapping("esColonoscopyCheckInfo")
@Api(tags = "肠镜检查相关资料接口")
public class EsColonoscopyCheckInfoController {

    @Autowired
    private EsColonoscopyCheckInfoService esColonoscopyCheckInfoService;

    @ApiOperation(value = "新增肠镜检查相关资料")
    @PostMapping(value = "add")
    public AjaxResult add(@RequestBody List<EsColonoscopyCheckInfoDto> esColonoscopyCheckInfoDto) {

        try {
            esColonoscopyCheckInfoService.add(esColonoscopyCheckInfoDto);
            return AjaxResult.success();
        } catch (Exception e) {
            e.printStackTrace();
            return AjaxResult.error();
        }
    }

    @ApiOperation(value = "根据checkId查询肠镜检查相关资料")
    @GetMapping(value = "getColonoscopyCheckInfoById")
    public AjaxResult getColonoscopyCheckInfoById(String checkId) {
        List<EsColonoscopyCheckInfoDto> esColonoscopyCheckInfoDto = esColonoscopyCheckInfoService.getColonoscopyCheckInfoById(checkId);
        return AjaxResult.success(esColonoscopyCheckInfoDto);
    }

    @ApiOperation(value = "根据id删除肠镜检查相关资料")
    @DeleteMapping(value = "delete/{id}")
    public AjaxResult delete(@PathVariable("id") String id) {
        esColonoscopyCheckInfoService.delete(id);
        return AjaxResult.success();
    }

}
